package pkg

import (
	"chat/consts"
	"encoding/json"
	"fmt"
	"github.com/Baidu-AIP/golang-sdk/aip/censor"
	"log"
)

type Cons struct {
	LogId          uint64 `json:"log_id"`
	ErrorCode      uint64 `json:"error_code"`
	ErrorMsg       string `json:"error_msg"`
	Conclusion     string `json:"conclusion"`
	ConclusionType uint64 `json:"conclusionType"`
}

func Dan(message string) string {
	client := censor.NewClient(consts.AK, consts.SK)
	//如果是百度云ak sk,使用下面的客户端
	res := client.TextCensor(message)
	fmt.Println(res)
	var resp Cons
	json.Unmarshal([]byte(res), &resp)
	log.Println(resp)
	if resp.ConclusionType == 1 {
		return "合规"
	} else {
		return "不合规"
	}
}
